package com.yc.entity;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;


public class TestNestEntity {

	public static void main(String[] args) {
		NestEntity parent = new NestEntity();
		List<NestEntity> children = new ArrayList<NestEntity>();
		parent.setChildren(children);
		NestEntity child1 = new NestEntity();
		NestEntity child2 = new NestEntity();
		children.add(child1);
		children.add(child2);
		
		parent.setId(1);
		child1.setId(2);
		child2.setId(3);
		parent.setName("第一节点");
		child1.setName("第二节点");
		child2.setName("第三节点");
		
		//转成json字符串
		String str = JSONObject.toJSONString(parent);
		System.out.println("str = " + str);
		
	}
}
